package douyubishi;

import java.util.*;

/**
 * Created by JiaJia on 2019/8/20 0020.
 */
public class BingjiJiaoji {
    public static void main(String[] args) {
        int[] a={1,2,3};
        int[] b={2,3,4,4};
        int[] c={3,5,5};
        System.out.println(union(a,b,c));
        System.out.println(intersect(a,b,c));
    }
    private static Set union(int[] a,int[] b,int[] c){
        Set<Integer> set=new HashSet<Integer>();
        for (int numa:a) {
            set.add(numa);
        }
        for (int numb:b) {
            set.add(numb);
        }
        for (int numc:c) {
            set.add(numc);
        }
        return set;
    }
    private static List<Integer> intersect(int[] a,int[] b,int[] c){
        ArrayList<Integer> list=new ArrayList<>();
        for (int num:a) {
            if (Arrays.asList(b).contains(num)&&Arrays.asList(c).contains(num)){
                list.add(num);
            }
        }
        return list;
    }
}